package com.lanren.common.utils;

import android.view.View;

/**
 * @ClassName Utils
 * @Description TODO
 * @Author chongheng.wang
 * @Date 2020/4/5 14:43
 * @Version 1.0
 */
public class Utils {
    // 两次点击间隔不能少于1000ms
    private static final int FAST_CLICK_DELAY_TIME = 1500;

    public static boolean isFastClick(View view) {
        return isFastClick(view, FAST_CLICK_DELAY_TIME);
    }

    public static boolean isFastClick(View view, int fastDelayTime) {
        long currentClickTime = System.currentTimeMillis();
        long viewLong = 0;
        if (view.getTag() != null) {
            viewLong = (long) view.getTag();
        }
        LogUtils.d("isFastClick viewLong=" + (currentClickTime - viewLong) + "  " + ((currentClickTime - viewLong) >= FAST_CLICK_DELAY_TIME));
        if ((currentClickTime - viewLong) >= fastDelayTime) {
            view.setTag(currentClickTime);
            return true;
        }
        return false;
    }
}
